<template>
  <div class="index">

    <div id="mws-themer">
      <div id="mws-themer-hide"></div>
      <div id="mws-themer-content">
        <div class="mws-themer-section">
          <label for="mws-theme-presets">Presets</label> <select id="mws-theme-presets"></select>
        </div>
        <div class="mws-themer-separator"></div>
        <div class="mws-themer-section">
          <ul>
            <li><span>Base Color</span>
              <div id="mws-base-cp" class="mws-cp-trigger"></div>
            </li>
            <li><span>Text Color</span>
              <div id="mws-text-cp" class="mws-cp-trigger"></div>
            </li>
            <li><span>Text Glow Color</span>
              <div id="mws-textglow-cp" class="mws-cp-trigger"></div>
            </li>
          </ul>
        </div>
        <div class="mws-themer-separator"></div>
        <div class="mws-themer-section">
          <ul>
            <li><span>Text Glow Opacity</span>
              <div id="mws-textglow-op"></div>
            </li>
          </ul>
        </div>
        <div class="mws-themer-separator"></div>
        <div class="mws-themer-section">
          <button class="mws-button red small" id="mws-themer-getcss">Get CSS</button>
        </div>
      </div>
      <div id="mws-themer-css-dialog">
        <div class="mws-form">
          <div class="mws-form-row" style="padding:0;">
            <div class="mws-form-item">
              <textarea cols="auto" rows="auto" readonly="readonly"></textarea>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- Themer End -->


    <!-- Header Wrapper -->
    <div id="mws-header" class="clearfix">

      <!-- Logo Wrapper -->
      <div id="mws-logo-container">
        <div id="mws-logo-wrap">
          <img src="../../static/images/mws-logo.png" alt="mws admin" />
        </div>
      </div>

      <!-- User Area Wrapper -->
      <div id="mws-user-tools" class="clearfix">

        <!--&lt;!&ndash; User Notifications &ndash;&gt;-->
        <!--<div id="mws-user-notif" class="mws-dropdown-menu">-->
        <!--<a href="#" class="mws-i-24 i-alert-2 mws-dropdown-trigger">Notifications</a>-->
        <!--&lt;!&ndash;<span class="mws-dropdown-notif">35</span>&ndash;&gt;-->
        <!--<div class="mws-dropdown-box">-->
        <!--<div class="mws-dropdown-content">-->
        <!--<ul class="mws-notifications">-->

        <!--&lt;!&ndash; Notification Content &ndash;&gt;-->
        <!--<li class="read">-->
        <!--<a href="#">-->
        <!--<span class="message">-->
        <!--Lorem ipsum dolor sit amet consectetur adipiscing elit, et al commore-->
        <!--</span>-->
        <!--<span class="time">-->
        <!--January 21, 2012-->
        <!--</span>-->
        <!--</a>-->
        <!--</li>-->
        <!--<li class="read">-->
        <!--<a href="#">-->
        <!--<span class="message">-->
        <!--Lorem ipsum dolor sit amet-->
        <!--</span>-->
        <!--<span class="time">-->
        <!--January 21, 2012-->
        <!--</span>-->
        <!--</a>-->
        <!--</li>-->
        <!--<li class="unread">-->
        <!--<a href="#">-->
        <!--<span class="message">-->
        <!--Lorem ipsum dolor sit amet-->
        <!--</span>-->
        <!--<span class="time">-->
        <!--January 21, 2012-->
        <!--</span>-->
        <!--</a>-->
        <!--</li>-->
        <!--<li class="unread">-->
        <!--<a href="#">-->
        <!--<span class="message">-->
        <!--Lorem ipsum dolor sit amet-->
        <!--</span>-->
        <!--<span class="time">-->
        <!--January 21, 2012-->
        <!--</span>-->
        <!--</a>-->
        <!--</li>-->
        <!--&lt;!&ndash; End Notification Content &ndash;&gt;-->

        <!--</ul>-->
        <!--<div class="mws-dropdown-viewall">-->
        <!--<a href="#">View All Notifications</a>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->

        <!-- User Messages -->
        <!--<div id="mws-user-message" class="mws-dropdown-menu">-->
        <!--<a href="#" class="mws-i-24 i-message mws-dropdown-trigger">Messages</a>-->
        <!--&lt;!&ndash;<span class="mws-dropdown-notif">35</span>&ndash;&gt;-->
        <!--<div class="mws-dropdown-box">-->
        <!--<div class="mws-dropdown-content">-->
        <!--<ul class="mws-messages">-->

        <!--&lt;!&ndash; Message Content &ndash;&gt;-->
        <!--<li class="read">-->
        <!--<a href="#">-->
        <!--<span class="sender">John Doe</span>-->
        <!--<span class="message">-->
        <!--Lorem ipsum dolor sit amet consectetur adipiscing elit, et al commore-->
        <!--</span>-->
        <!--<span class="time">-->
        <!--January 21, 2012-->
        <!--</span>-->
        <!--</a>-->
        <!--</li>-->
        <!--<li class="read">-->
        <!--<a href="#">-->
        <!--<span class="sender">John Doe</span>-->
        <!--<span class="message">-->
        <!--Lorem ipsum dolor sit amet-->
        <!--</span>-->
        <!--<span class="time">-->
        <!--January 21, 2012-->
        <!--</span>-->
        <!--</a>-->
        <!--</li>-->
        <!--<li class="unread">-->
        <!--<a href="#">-->
        <!--<span class="sender">John Doe</span>-->
        <!--<span class="message">-->
        <!--Lorem ipsum dolor sit amet-->
        <!--</span>-->
        <!--<span class="time">-->
        <!--January 21, 2012-->
        <!--</span>-->
        <!--</a>-->
        <!--</li>-->
        <!--<li class="unread">-->
        <!--<a href="#">-->
        <!--<span class="sender">John Doe</span>-->
        <!--<span class="message">-->
        <!--Lorem ipsum dolor sit amet-->
        <!--</span>-->
        <!--<span class="time">-->
        <!--January 21, 2012-->
        <!--</span>-->
        <!--</a>-->
        <!--</li>-->
        <!--&lt;!&ndash; End Messages &ndash;&gt;-->

        <!--</ul>-->
        <!--<div class="mws-dropdown-viewall">-->
        <!--<a href="#">View All Messages</a>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->

        <!-- User Functions -->
        <div id="mws-user-info" class="mws-inset">
          <div id="mws-user-photo">
            <img src="../../static/example/profile.jpg" alt="User Photo" />
          </div>
          <div id="mws-user-functions">
            <div id="mws-username">
              Hello, {{user.username}}
            </div>
            <ul>
              <!--<li><a href="#">Profile</a></li>-->
              <!--<li><a href="#">Change Password</a></li>-->
              <li>
                <router-link to="login" @click="goOut">退出</router-link>
              </li>
            </ul>
          </div>
        </div>
        <!-- End User Functions -->

      </div>
    </div>

    <!-- Main Wrapper -->
    <div id="mws-wrapper">
      <!-- Necessary markup, do not remove -->
      <div id="mws-sidebar-stitch"></div>
      <div id="mws-sidebar-bg"></div>

      <!-- Sidebar Wrapper -->
      <div id="mws-sidebar">

        <!-- Search Box -->
        <!--<div id="mws-searchbox" class="mws-inset">-->
        <!--<form action="http://www.malijuwebshop.com/themes/mws-admin/dashboard.html">-->
        <!--<input type="text" class="mws-search-input" />-->
        <!--<input type="submit" class="mws-search-submit" />-->
        <!--</form>-->
        <!--</div>-->

        <!-- Main Navigation -->
        <div id="mws-navigation">
          <ul>
            <li :class="selected=='QList'?'active':''"><a href="javascript:;" @click="goPage('QList','checkList')"
                                                          class="mws-i-24 i-home">问题列表</a></li>
            <!--<li><a href="charts.html" class="mws-i-24 i-chart">Charts</a></li>-->
            <!--<li><a href="calendar.html" class="mws-i-24 i-day-calendar">Calendar</a></li>-->
            <!--<li><a href="files.html" class="mws-i-24 i-file-cabinet">File Manager</a></li>-->
            <!--<li><a href="table.html" class="mws-i-24 i-table-1">Table</a></li>-->
            <!--<li>-->
            <!--<a href="#" class="mws-i-24 i-list">Forms</a>-->
            <!--<ul>-->
            <!--<li><a href="form_layouts.html">Layouts</a></li>-->
            <!--<li><a href="form_elements.html">Elements</a></li>-->
            <!--</ul>-->
            <!--</li>-->
            <!--<li><a href="widgets.html" class="mws-i-24 i-cog">Widgets</a></li>-->
            <!--<li><a href="typography.html" class="mws-i-24 i-text-styling">Typography</a></li>-->
            <!--<li><a href="grids.html" class="mws-i-24 i-blocks-images">Grids &amp; Panels</a></li>-->
            <li :class="selected=='addList'?'active':''" v-if="ceshi===true"><a href="javascript:;"
                                                                                @click="goPage('addList','addList')"
                                                                                class="mws-i-24 i-alert-2">新问题</a></li>
            <li :class="selected=='comfirm'?'active':''" v-if="ceshi===true"><a href="javascript:;"
                                                                                @click="goPage('comfirm','comfirm')"
                                                                                class="mws-i-24 i-cog">测问题</a></li>
            <!--<li :class="selected=='AList'?'active':''"><a href="javascript:;" @click="goPage('AList','aList')" class="mws-i-24 i-polaroids">修BUG</a></li>-->
            <li :class="selected=='AList'?'active':''" v-if="web===true"><a href="javascript:;" @click="goPage('AList','aList')"
                                                                 class="mws-i-24 i-cog">修BUG</a></li>
            <!--<li>-->
            <!--<a href="icons.html" class="mws-i-24 i-pacman">-->
            <!--Icons <span class="mws-nav-tooltip">2000+</span>-->
            <!--</a>-->
            <!--</li>-->
          </ul>
        </div>
        <!-- End Navigation -->

      </div>
      <router-view />
    </div>
    <!-- End Main Wrapper -->
  </div>
</template>

<script>
  export default {
    name: 'index',
    data() {
      return {
        baseUrl: 'http://47.95.200.225:80',
        // baseUrl: 'http://192.168.0.147:8000',
        selected: '',
        user: [],
        ceshi: false,
        web: false
      }
    },
    methods: {
      goPage(id, page) {
        this.$store.commit('changeName', id)
        this.selected = this.$store.state.pageName.pageName
        this.$router.push({path: '/' + page})
      },
      goOut() {
        let self = this
        sessionStorage.clear()
        self.$router.push({path: '/login'})
      }
    },
    mounted() {
      let self = this
      let login = sessionStorage.getItem('userDetail')
      if (login) {
        this.user = JSON.parse(login)
      } else {
        self.$router.push({path: '/login'})
      }
      this.selected = this.$store.state.pageName.pageName

      // qa.change_qawatch
      let params = new URLSearchParams()
      params.append('username', self.user.username)
      self.$ajax
        .post(self.baseUrl + '/checkLevel/', params)    //文章收藏
        .then(function (res) {
          if (res.data.status === 'ok') {
            if (res.data.data.indexOf('qa.add_qawatch') !== -1) {
              self.web = true
            }
            if (res.data.data.indexOf('qa.add_qclass') !== -1) {
              self.ceshi = true
            }
          }
        })
        .catch(function (response) {
          console.log(response)
        })
    },
  }
</script>

<style scoped>
  .index {
    height: 100%;
  }
</style>
